<?php
$this->headTitle($this->translator('customer_evaluation_page_title'));
?>

<style>
	.caption{
		font-weight: bold;
		background: #BCBBB9;
	}
	tr.none_border td{
		border-bottom:0;
	}
    table{
		border-top:none;
		border-bottom:none;
	}
	.list table{
		width: 100%;
		border-top: 0px;
		border-bottom: 0px;
	}
	.list .caption td{
		font-weight: bold;
		background: #BCBBB9;
	}
	.list tr.caption:hover td{
		font-weight: bold;
		background: #BCBBB9;
	}
	.list tbody tr:hover td{
		background: #EFEDED;
	}
	label{
        display:block;
        float:left;
        height:26px;
        line-height:15px;
        margin-right:20px;
        width:120px;
    }    
</style>
<?php 
	$enterprise = $this->enterprise;	
	$e_name = ($this->lang == 'vi_VN')?$enterprise->company_name_vn:$enterprise->company_name_en;
	$arrRoute = array(
        'enterprise_id' => $enterprise->id,
        'enterprise_name' => Tomato_Utility_String::removeSign($enterprise->company_name_en, '-', true),
    );
?>
<div class="grid_12">
    <div class="grid_12 alpha">
        <div class="icon_title"><span><?php echo $this->translator('customer_evaluation_of_enterprise');?>: <a href="<?php echo $this->url($arrRoute,'bizprofile_enterprise_index');?>"><?php echo $e_name;?></a></span></div>
    </div>
    <div class="t_a_bottom"><hr style="padding:0;"/></div>
    <div class="grid_10 t_a_bottom">
        <div class="clearfix t_a_bottom">
            <?php echo $this->translator('customer_evaluation');?>:
        	<?php if(@$this->enterprise->evaluation_counter):?>
            <b> <?php echo isset($this->enterprise->evaluation_point)?$this->enterprise->evaluation_point:0;?></b>(<?php echo $this->translator('customer_evaluation_point');?>) / <b><?php echo isset($this->enterprise->evaluation_counter)?$this->enterprise->evaluation_counter:0;?></b>(<?php echo $this->translator('customer_evaluation_counter');?>)
            <?php else:?>
            <?php echo $this->translator('enterprise_not_feedback_yet');?>
            <?php endif;?>
        </div>
    </div>
    <div class="grid_10" style="height:20px;">&nbsp;</div>

    <!--Tab-->
    <div class="subcolumns tabs pb10">
        <ul class="tabNavigation">
            <li><a href="#tab1" id="seller" val="" rel="seller"><?php echo $this->translator('customer_evaluation_seller')?></a></li>            
            <li><a href="#tab2" id="buyer" val="" rel="buyer"><?php echo $this->translator('customer_evaluation_buyer')?></a></li>
        </ul>        
        <div id="tab1">
            <div id="sellerOutput" class="grid_12"></div>
        </div>
        <div id="tab2" style="display: block;">
            <div id="buyerOutput" class="grid_12"></div>
        </div>
    </div>
    <!--end tab-->
</div>

<script type="text/javascript" charset="utf-8">
    $(function () {
        var tabContainers = $('div.tabs > div');
        tabContainers.hide().filter(':first').show();

        $('div.tabs ul.tabNavigation a').click(function () {
                tabContainers.hide();
                tabContainers.filter(this.hash).show();
                $('div.tabs ul.tabNavigation a').removeClass('selected');
                $(this).addClass('selected');
                return false;
        }).filter(':first').click();
    });
</script>
<script type="text/javascript">
$(document).ready(function() {

    $('div.tabs ul.tabNavigation a').click(function () {
        key = $(this).attr('rel');
        val = $(this).attr('val');
        if(key == 'buyer' && val != 'is_loaded'){
            buyerAjax();
        }
        else if(key == 'seller' && val != 'is_loaded'){
            sellerAjax();
        }
    });
    /**Auto load ajax*/
    sellerAjax();
});

function buyerAjax(){
    $("#buyerOutput").html('').addClass('t_a_ui_helper_loading');
    jQuery.ajaxq('buyer', {
        type: 'POST',
        url: "<?php echo $this->url(array('user_id' => $this->exp_id), 'customer_evaluation_buyer'); ?>",        
        success: function(html) {
            $("#buyerOutput").html('').removeClass('t_a_ui_helper_loading');
            $('#buyerOutput').html(html);

            /**
            * Set is loaded
            */
            $('#buyer').attr('val', 'is_loaded');
        }
    });
}

function sellerAjax(){
    $("#sellerOutput").html('').addClass('t_a_ui_helper_loading');
    jQuery.ajaxq('seller', {
        type: 'POST',
        url: "<?php echo $this->url(array('user_id' => $this->exp_id), 'customer_evaluation_seller'); ?>",
        data: {},
        success: function(html) {
            $("#sellerOutput").html('').removeClass('t_a_ui_helper_loading');
            $('#sellerOutput').html(html);

            /**
            * Set is loaded
            */
            $('#seller').attr('val', 'is_loaded');
        }
    });
}
</script>